//
// Created by francklinson on 2021/7/4.
//
#include <vector>
#include <unordered_map>
#include <iostream>


using namespace std;

class Solution {
public:
    vector<int> findErrorNums(vector<int> &nums) {
        vector<int> errorNums(2);
        int n = (int) nums.size();
        unordered_map<int, int> mp;
        for (auto &num : nums) {
            mp[num]++;
        }
        for (int i = 1; i <= n; i++) {
            int count = mp[i];
            if (count == 2) {
                errorNums[0] = i;
            } else if (count == 0) {
                errorNums[1] = i;
            }
        }
        return errorNums;
    }
};

int main() {
    vector<int> nums{1, 2, 2, 4};
    Solution sol;
    auto ans = sol.findErrorNums(nums);
    for (auto &x:ans) cout << x << endl;
    return 0;
}

